<?php

namespace Summer\Sms\Http\Controllers;

use Illuminate\Routing\Controller;
use Summer\Hub\Http\Controllers\Traits\ApiReturn;
use Summer\Sms\Classes\SmsApi;
use Summer\Sms\Http\Requests\SmsSendRequest;
use Summer\Sms\Models\Settings;
use Input;
use Db;
use Event;


class SmsController extends Controller
{
    use ApiReturn;

    public function send(SmsSendRequest $request)
    {
        $request->validate();
        $mobile=Input::get('mobile');
        $scene_slug=Input::get('scene_slug','base_code');
        $code=mt_rand(1000, 9999);
        //这里调用发送验证码
        $sms_config=Settings::instance();
        if($sms_config->is_check!=1){
            return $this->apiSuccess('操作成功,短信验证关闭');
        }else{
            $sms_api=new SmsApi();
            $res=$sms_api->send($mobile,$scene_slug,['code'=>$code]);
            return $this->apiSuccess('操作成功');
        }
    }


}
